package org.mzyyn.qr.service.auction.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.mzyyn.qr.entity.AuctionOrderPO;
import org.mzyyn.qr.mapper.AuctionOrderMapper;
import org.mzyyn.qr.service.auction.AuctionOrderService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;

/**
 * <p>
 * 拍卖订单表 服务实现类
 * </p>
 *
 * @author lipeng
 * @since 2024-09-24
 */
@Service
public class AuctionOrderServiceImpl extends ServiceImpl<AuctionOrderMapper, AuctionOrderPO> implements AuctionOrderService {
    @Override
    public void addOrder(String uuid, Long goodsId, Long cjPrice){
        AuctionOrderPO auctionOrderPO = new AuctionOrderPO();
        auctionOrderPO.setUserUuid(uuid);
        auctionOrderPO.setGoodsId(goodsId);
        auctionOrderPO.setCjPrice(cjPrice);
        auctionOrderPO.setCreateTime(LocalDateTime.now());
        auctionOrderPO.setUpdateTime(LocalDateTime.now());

        this.baseMapper.insert(auctionOrderPO);

    }

    @Override
    public AuctionOrderPO getOrderByGoodsId(Long goodsId) {
        LambdaQueryWrapper<AuctionOrderPO> query = new LambdaQueryWrapper<>();
        query.eq(AuctionOrderPO::getGoodsId, goodsId);

        return this.getOne(query);
    }
}
